import { ResultCallback, RecorderType, SDKRecorderState } from "../../SDKDefine";
import SdkEventList from "../../tools/SdkEventList";
import { BaseSDK } from "../base/BaseSDK";



export default class BaseRecorder extends BaseSDK {


    protected recorder: any;

    protected videoPath: string = null;

    protected state: SDKRecorderState = SDKRecorderState.stop

    protected data: RecorderType;
    protected event: SdkEventList = new SdkEventList();

    setData(cfg: RecorderType) {
        this.data = cfg;
    }

    init() {

    }
    on(func: Function) {
        this.event.on(func)
    }
    off(func: Function) {
        this.event.off(func)
    }

    emit(data: any) {
        this.event.emit(data)
    }

    start(obj?: any) { }
    pause() { }
    resume() { }
    stop(isSave: boolean = true, callback: (r: number) => void) {

    }
    //记录精彩的视频片段
    recordClip(object: any) { }

    changeState(s: SDKRecorderState) {
        this.state = s;
        this.emit(this.state)
    }

    getVideoPath() {
        return this.videoPath;
    }

    clear() {
        this.videoPath = null;
    }

    isOpen() {
        return this.state == SDKRecorderState.open;
    }

    isClose() {
        return this.state == SDKRecorderState.stop;
    }

    getState() {
        return this.state;
    }

    publish(callback: ResultCallback) { }

}
